<template>
<t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
    </t-image-viewer>
    <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
    </van-image-preview>
  <div class="outline-parent">
    
    <img class="outline-parent-bg" :src="publicUrls + 'free/style2/Auxiliaryoutlinestyle3Bg.webp'" alt="" />
    <div class="outline border-hover-style">
      <div
        class="outline-box"
        :style="
          !props.info.subTitle &&
          !props.info.value &&
          !(props.info.video && props.info.video.url) && { justifyContent: 'flex-start' }
        "
      >
        <div class="outline-title">
          <div class="title">
            <p
              :class="index == props.info.text?.length - 1 && 'brush'"
              v-for="(item, index) in props.info.text"
              :key="index"
            >
              {{ item }}
            </p>
          </div>
          <div
            class="audio-box"
            :class="isPlay && 'audio-rotate'"
            v-if="props.info.audio && props.info.audio.url"
            @click="audioplay(true)"
          >
            <i class="doorIcon">&#xe688;</i>
          </div>
          <audio
            v-if="props.info.audio && props.info.audio.url"
            :src="urls + props.info.audio.url"
            ref="audioRef"
          ></audio>
        </div>
        <div class="outline-subTitle" v-if="props.info.subTitle">
          {{ props.info.subTitle }}
        </div>
        <div class="outline-content">
          <div class="left-Text" v-if="props.info.remarks">
            <TextMax
              v-if="props.domShow"
              :data="props.info.remarks"
              :title="props.info.text"
              :infoData="props.info"
              :row="
                props.info.subTitle && props.info.text?.length <= 6
                  ? 8
                  : !props.info.value && !(props.info.video && props.info.video.url) && props.info.text?.length <= 6
                  ? 9
                  : !props.info.subTitle && props.info.text?.length <= 6
                  ? 9
                  : !props.info.subTitle && props.info.text?.length > 6
                  ? 8
                  : 6
              "
            ></TextMax>
          </div>
          <div
            class="content-item"
            v-if="props.info.value || (props.info.video && props.info.video.url)"
            :style="!props.info.remarks && !props.info.subTitle && { marginLeft: 0 }"
          >
            <div class="medium">
              <img
                v-if="props.info.value && !(props.info.video && props.info.video.url)"
                class="outline-cover"
                @click="ImgVisible = true"
                :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
                alt=""
              />
              <!-- <div class="mask-layer" v-show="isPlay && props.info.video && props.info.video.url" @click="videoplay">
                <div class="round">
                  <span v-if="isPlay" class="freeIcon">&#xe672;</span><span v-else class="freeIcon">&#xe671;</span>
                </div>
              </div> -->
              <videoview @click="audioplay(false)" :info="props.info"></videoview>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free2Style3',
});
</script>

<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import videoview from './../../../videoDialog/videoview.vue';

const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style scoped lang="less">
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 30% linear-gradient(transparent, rgba(0, 0, 0, 0.15));
}
.outline-parent-bg {
  width: 708px;
  height: 430px;
  // margin-top: 238px;
  margin-top: 78px;
  margin-right: 10px;
}
.outline {
  position: absolute;
  // top: 240px;
  top: 80px;
  left: 0;
  z-index: 20;
  width: 708px;
  height: 430px;
  padding: 26px 66px 30px 30px;
}
.outline-box {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.outline-title {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  position: relative;
  margin-bottom: 24px;
  .title {
    max-width: 250px;
    display: flex;
    flex-wrap: wrap;
    p {
      width: 31px;
      height: 30px;
      flex-shrink: 0;
      font-family: SourceHanSerifCN-Bold;
      font-size: 20px;
      line-height: 30px;
      color: #ebf8f7;
      text-align: center;
      background: url('https://static.jiyi.show/free/style2/textBg.webp') no-repeat center/100% 100%;
      margin-right: 4px;
      position: relative;
      margin-top: 4px;
      &:nth-child(7) {
        margin-left: 35px;
      }
    }
    .brush {
      &::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 36px;
        transform: translate(0, -50%);
        width: 64px;
        height: 22px;
        background: url('https://static.jiyi.show/free/style2/brush.webp') no-repeat center/100% 100%;
      }
    }
  }
}
.outline-content {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  // height: 192px;
  // flex-shrink: 0;
  overflow: hidden;
}
.left-Text {
  width: 100%;
}
.outline-subTitle {
  width: 100%;
  margin-bottom: 24px;
  font-family: SourceHanSerifCN;
  font-size: 18px;
  color: #212326;
  line-height: 28px;
  opacity: 63%;
}
.content-item {
  position: relative;
  width: 100%;
  height: 100%;
  margin-left: 16px;
}
.medium {
  width: 100%;
  height: 100%;
  position: relative;

  .mask-layer {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    position: absolute;
    top: 50%;
    transform: translate(0%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    .round {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      border: 2px solid rgba(255, 245, 228, 1);
      text-align: center;
      .freeIcon {
        font-size: 24px;
        line-height: 38px;
        color: rgba(255, 245, 228, 1);
      }
    }
  }
  .outline-cover {
    width: 100%;
    height: 100%;
    object-fit: contain;
    overflow: hidden;
  }
}

.audio-rotate {
  animation: audio-rotate 3s linear infinite;
  @keyframes audio-rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}

.audio-box {
  position: absolute;
  top: 0;
  right: 0;
  // transform: translate(0, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #ffdc76;
  border-radius: 50%;
  box-shadow: 0px 2px 4px #0000001a;
  .doorIcon {
    font-size: 24px;
    color: #5b8c87;
  }
}

::v-deep .van-text-ellipsis {
  font-family: SourceHanSerifCN-Medium !important;
  font-size: 16px !important;
  color: rgba(33, 35, 38) !important;
  line-height: 32px !important;
}
::v-deep .van-text-ellipsis__action::before {
  color: #ffdc76 !important;
  font-weight: 400 !important;
  text-decoration-line: underline;
}
::v-deep .t-popup__content {
  background: #5b8c87;
  box-shadow: none;
  padding: 4px 10px;
  font-size: 14px !important;
  line-height: 22px;
  color: #fff;
  box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.1), 0px 8px 10px 1px rgba(0, 0, 0, 0.06),
    0px 3px 14px 2px rgba(0, 0, 0, 0.05);
}
::v-deep .t-popup__arrow::before {
  background: #5b8c87;
  border: none;
  box-shadow: none !important;
}
</style>
